const AutoImport = require('unplugin-auto-import/webpack');
const Components = require('unplugin-vue-components/webpack');
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers');
module.exports = {
  configureWebpack: {
    externals: {
      BMapGL: 'BMapGL',
    },
    resolve: {
      alias: {
        // "@":"src"  已经配置过了
        components: '@/components',
        network: '@/network',
        views: '@/views',
        assets: '@/assets',
        utils: '@/utils',
        modelUtils: '@/modelUtils',
      },
    },
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
  },
  lintOnSave: false,
  publicPath: './',
  pages: {
    index: {
      // page 的入口
      entry: 'src/main.js',
      // 模板来源
      template: 'public/index.html',
      // 在 dist/index.html 的输出
      filename: 'index.html',
      // 当使用 title 选项时，
      // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
      // title: '杭州亚运会保障系统',
      // title: '杭州亚残运会保障系统',
      // title: '大型活动医疗急救保障系统',
      // title: " 安克赛事活动保障系统",
      title: "哈尔滨亚冬医疗急救保障系统",
    },
  },
  devServer: {
    port: 9111,
    https: true,
    hotOnly: false,
    proxy: {
      '/api': {
        target: 'http://123.164.6.159:44410/api',
        ws: true,
        changeOrigin: true, //本地是否开启代理
        pathRewrite: {
          '^/api': '',
        },
      },
      '/cockpit': {
        // target: 'http://172.16.100.176:8545',
        target: 'https://123.164.6.159:44426',

        ws: true,
        changeOrigin: true, //本地是否开启代理
        pathRewrite: {
          '^/cockpit': '',
        },
      },
      '/Content': {
        target: 'https://123.164.6.159:44426/Content',
        ws: true,
        changeOrigin: true, //本地是否开启代理
        pathRewrite: {
          '^/Content': '',
        },
      },
      '/Visual': {
        target: 'https://123.164.6.159:44426/Visual',
        ws: true,
        changeOrigin: true, //本地是否开启代理
        pathRewrite: {
          '^/Visual': '',
        },
      },
    },
  },
  css: {
    loaderOptions: {
      sass: {
        // 8版本用prependData:
        prependData: `
              @import "@/styles/variables.scss";  // scss文件地址
              @import "@/styles/mixin.scss";     // scss文件地址
            `,
      },
    },
  },
  chainWebpack: (config) => {
    //去掉v-i18n浏览器告警部分
    config.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js');
  },
};
